package test.dao;

import org.junit.Before;
import org.junit.Test;
import org.nutz.dao.Dao;
import org.nutz.dao.impl.NutDao;
import org.nutz.dao.impl.SimpleDataSource;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;

import com.kerbores.utils.db.SqlActuator;

/**
 * @author Ixion
 *
 *         create at 2014年9月4日
 */
public class Dao_ {

	Dao dao;

	@Before
	public void init() {
		SimpleDataSource dataSource = new SimpleDataSource();
		try {
			dataSource.setDriverClassName("oracle.jdbc.OracleDriver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		dataSource.setJdbcUrl("jdbc:oracle:thin:@10.0.1.100:1521:orcl");
		dataSource.setUsername("bb");
		dataSource.setPassword("bb");
		dao = new NutDao(dataSource);
	}

	@Test
	public void testDao() {
		System.out.println(Json.toJson(SqlActuator.runReport("select * from user_test", dao), JsonFormat.nice()));
	}
}
